package com.user.profile.service.label;

import com.user.profile.request.SaveLabelRequest;
import com.user.profile.request.SaveLabelRequest.UserInfo;
import java.util.Map;
import javafx.util.Pair;

/**
 * @Author linlx
 * @Date 2021/9/18 13:47
 * @Description
 **/
public abstract class AbstractCkBuildService {

  /**
   * @return bitmapOr(user0, bitmapAnd ( user3, bitmapOr ( user1, user2)))
   * @Author linlx
   * @date 2021/9/18 14:21
   * @Description 将用户标签拼接为ClickHouse语句
   */
  public final String buildCkQuery(SaveLabelRequest request) {
    Pair<StringBuilder, Map<Integer, UserInfo>> pair = this
        .buildAllOperate(request);
    return this.buildCkSQL(pair, request.getParentOperate());
  }

  /**
   * @Author linlx
   * @date 2021/9/18 14:21
   * @Description 将用户标签转换为bitmap函数
   */
  public abstract Pair<StringBuilder, Map<Integer, UserInfo>> buildAllOperate(
      SaveLabelRequest request);

  /**
   * @Author linlx
   * @date 2021/9/18 14:21
   * @Description 将用户标签转换为ClickHouse语句
   */
  public abstract String buildCkSQL(Pair<StringBuilder, Map<Integer, UserInfo>> pair,
      Integer parentOperate);

}
